package com.cango.framework.base.job;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

/**
 * Created by weih on 2016/10/21.
 */
public class MailSender {
    /**
     * log
     */
    private final Log log = LogFactory.getLog(MailSender.class);
    private JavaMailSender sender;

    private String from;

    public void sendMail(SimpleMailMessage msg) {
        try {
            msg.setFrom(from);

            sender.send(msg);
        } catch (Exception e) {
            log.error("发送邮件发生错误", e);
            throw e;
        }
    }

    public JavaMailSender getSender() {
        return sender;
    }

    public void setSender(JavaMailSender sender) {
        this.sender = sender;
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }
}
